import { ElMessage, ElMessageBox } from 'element-plus';

//消息提示-成功
export const $msg_s = (message, duration = 2000) => {
  ElMessage({
    showClose: true,
    message,
    duration,
    type: 'success',
  });
}

//消息提示-警告
export const $msg_w = (message, duration = 2000) => {
  ElMessage({
    showClose: true,
    message,
    duration,
    type: 'warning',
  });
}

//消息提示-错误
export const $msg_e = (message, duration = 2000) => {
  ElMessage({
    showClose: true,
    message,
    duration,
    type: 'error',
  });
}

//消息弹出框-确认消息
export const $confirm = (message, title = '提示', type = 'warning') => {
  return new Promise((resolve) => {
    ElMessageBox.confirm(
      message,
      title,
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type,
      }
    )
      .then(() => {
        resolve();
      })
      .catch(() => {});
  });
}